home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cpp-olib.zip / DEMOS.ZIP / VIDDEMO.CPP < prev    next >
C/C++ Source or Header  |  1992-12-28  |  10KB  |  363 lines

  1. //**************************************************************************
  2. //      This is a demo program to show how to use some of the features of
  3. //      the VIDBIOS libraries of the ObjectEase package. To compile and run
  4. //      this program create a project file including the files TUI_L.LIB,
  5. //      VIDBIOSL.LIB, and VIDDEMO.CPP. Make sure that these files are located
  6. //      where the project says they are. You may also need to modify the path
  7. //      to the files VIDBIOS.H and TUI.H in the #includes portion of this
  8. //      file.
  9. //
  10. //      BE SURE YOU ARE COMPILING FOR THE LARGE MEMORY MODEL!!!
  11. //**************************************************************************
  12.  
  13. #include "tui.h"
  14. #include "vidbios.h"
  15. #include <conio.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18.  
  19. //*************************  FUNCTION PROTOTYPES  **************************
  20.  
  21. void intro();
  22. void demo1();
  23. void demo2();
  24. void demo3();
  25. void demo4();
  26. void demo5();
  27. void demo6();
  28. void outro();
  29.  
  30. //***************************  GLOBAL VARIABLES  ***************************
  31.  
  32. unsigned char def_pal[17];
  33. extern Mcursor the_mouse;
  34.  
  35. //**************************************************************************
  36. //              MAIN
  37. //**************************************************************************
  38.  
  39. void main()
  40. {
  41.     the_mouse.init();
  42.     cursoroff();
  43.     settext(7,0);
  44.     clrscr();
  45.     intro();
  46.     demo1();
  47.     settext(7,0);
  48.     clrscr();
  49.     demo2();
  50.     settext(7,0);
  51.     clrscr();
  52.     demo3();
  53.     settext(7,0);
  54.     clrscr();
  55.     demo4();
  56.     settext(7,0);
  57.     clrscr();
  58.     demo5();
  59.     settext(7,0);
  60.     clrscr();
  61.     demo6();
  62.     clear(32,0,0);
  63.     dlay(18);
  64.  
  65.     settext(7,0);
  66.     clrscr();
  67.     cursoron();
  68.     puts("Thank you for previewing the ObjectEase library from");
  69.     puts("David S. Reinhart Associates");
  70.     exit(0);
  71. }
  72.  
  73. //*************************************************************************
  74.  
  75. void intro()
  76. {
  77.     Twindow introwindow;
  78.     introwindow.init(4,6,77,18,14,2,0,0);
  79.     introwindow.title("Introduction");
  80.     introwindow.show();
  81.  
  82.     printc(8,14,2,"This short demo program highlights the video bios features of the");
  83.     printc(9,14,2,"ObjectEase library. Note that these library functions will work ONLY on");
  84.     printc(10,14,2,"VGA cards. If the program you are developing is intended for use on");
  85.     printc(11,14,2,"a variety of video equipment, be sure to test for the existence of");
  86.     printc(12,14,2,"a VGA card before calling these functions. If using an accelerated");
  87.     printc(13,14,2,"video card the fade routines will happen too quickly to be" );
  88.     printc(14,14,2,"appreciated. They will work fine on any standard VGA card.");
  89.     printc(16,15,2,"Press any key now to get on with the show...");
  90.  
  91.     getch();
  92.     introwindow.hide();
  93.     flushkeys();
  94. }
  95.  
  96. //*************************************************************************
  97.  
  98. void demo1()
  99. {
  100.     Twindow demo1window;
  101.  
  102.     demo1window.init(40,8,76,13,15,1,0,0);
  103.     demo1window.show();
  104.     printat(42,10,15,1," Fade any individual palette color");
  105.     printat(42,11,15,1,"     in and out as desired.     ");
  106.  
  107.     printat(5,5,1,0,"Blue         ████████");
  108.     printat(5,6,2,0,"Green        ████████");
  109.     printat(5,7,3,0,"Cyan         ████████");
  110.     printat(5,8,4,0,"Red          ████████");
  111.     printat(5,9,5,0,"Magenta      ████████");
  112.     printat(5,10,6,0,"Brown        ████████");
  113.     printat(5,11,7,0,"Lt. Gray     ████████");
  114.     printat(5,12,8,0,"Dk. Gray     ████████");
  115.     printat(5,13,9,0,"Br. Blue     ████████");
  116.     printat(5,14,10,0,"Br. Green    ████████");
  117.     printat(5,15,11,0,"Br. Cyan     ████████");
  118.     printat(5,16,12,0,"Br. Red      ████████");
  119.     printat(5,17,13,0,"Br. Magenta  ████████");
  120.     printat(5,18,14,0,"Yellow       ████████");
  121.     printat(5,19,15,0,"White        ████████");
  122.  
  123.     delay(1500);
  124.     for(int i=1;i<16;i++) {
  125.         fadeout(i);
  126.         fadein(i);
  127.         }
  128.     demo1window.fill();
  129.     printat(42,11,15,1,"         Press any key...   ");
  130.     getch();
  131.     flushkeys();
  132.     demo1window.hide();
  133. }
  134.  
  135. //**************************************************************************
  136.  
  137. void demo2()
  138. {
  139.     Twindow demo2window;
  140.     demo2window.init(20,5,61,10,15,1,0,0);
  141.     demo2window.show();
  142.     printc(7,15,1,"Instantly set any color to black,");
  143.     printc(8,15,1,"then fade in when appropriate.");
  144.  
  145.     Twindow greenwindow;
  146.     Twindow cyanwindow;
  147.     Twindow redwindow;
  148.     Twindow magentawindow;
  149.     Twindow brownwindow;
  150.  
  151.     greenwindow.init(15,12,25,17,2,2,0,0);
  152.     blankcolor(2);
  153.     cyanwindow.init(25,12,35,17,3,3,0,0);
  154.     blankcolor(3);
  155.     redwindow.init(35,12,45,17,4,4,0,0);
  156.     blankcolor(4);
  157.     magentawindow.init(45,12,55,17,5,5,0,0);
  158.     blankcolor(5);
  159.     brownwindow.init(55,12,65,17,6,6,0,0);
  160.     blankcolor(6);
  161.  
  162.     greenwindow.show();
  163.     cyanwindow.show();
  164.     redwindow.show();
  165.     magentawindow.show();
  166.     brownwindow.show();
  167.  
  168.     delay(1500);
  169.     fadein(2);
  170.     delay(500);
  171.     fadein(3);
  172.     delay(500);
  173.     fadein(4);
  174.     delay(500);
  175.     fadein(5);
  176.     delay(500);
  177.     fadein(6);
  178.     delay(500);
  179.  
  180.     demo2window.fill();
  181.     printc(8,15,1,"Press any key...");
  182.     getch();
  183.     flushkeys();
  184.     brownwindow.hide();
  185.     magentawindow.hide();
  186.     redwindow.hide();
  187.     cyanwindow.hide();
  188.     greenwindow.hide();
  189.     demo2window.hide();
  190. }
  191.  
  192. //**************************************************************************
  193.  
  194. void demo3()
  195. {
  196.     Twindow demo3window;
  197.  
  198.     demo3window.init(10,5,71,7,15,2,0,0);
  199.     demo3window.show();
  200.     printc(6,15,2,"\"Slide\" from one color into the next for exciting effects!");
  201.  
  202.     Twindow slidewindow;
  203.     slidewindow.init(20,12,61,22,1,1,0,0);
  204.     slidewindow.show();
  205.     delay(1000);
  206.     fade1_3();
  207.     delay(500);
  208.     fade3_1();
  209.     delay(500);
  210.     fade1_4();
  211.     delay(500);
  212.     fade4_1();
  213.     delay(500);
  214.     fade1_5();
  215.     delay(500);
  216.     fade5_1();
  217.     delay(500);
  218.  
  219.     demo3window.fill();
  220.     printc(6,15,2,"Press any key...");
  221.     getch();
  222.     flushkeys();
  223.     slidewindow.hide();
  224.     demo3window.hide();
  225. }
  226.  
  227. //**************************************************************************
  228.  
  229. void demo4()
  230. {
  231.     Twindow demo4window;
  232.     int r,g,b,i;
  233.  
  234.     demo4window.init(40,5,75,14,15,1,0,0);
  235.     demo4window.show();
  236.     printat(42,7,15,1,"   Bored with the standard 16");
  237.     printat(42,8,15,1,"         color palette?");
  238.     printat(42,10,15,1,"           CHANGE IT!");
  239.  
  240.     printat(5,5,1,0,"Color 1      ████████");
  241.     printat(5,6,2,0,"Color 2      ████████");
  242.     printat(5,7,3,0,"Color 3      ████████");
  243.     printat(5,8,4,0,"Color 4      ████████");
  244.     printat(5,9,5,0,"Color 5      ████████");
  245.     printat(5,10,6,0,"Color 6      ████████");
  246.     printat(5,11,7,0,"Color 7      ████████");
  247.     printat(5,12,8,0,"Color 8      ████████");
  248.     printat(5,13,9,0,"Color 9      ████████");
  249.     printat(5,14,10,0,"Color 10     ████████");
  250.     printat(5,15,11,0,"Color 11     ████████");
  251.     printat(5,16,12,0,"Color 12     ████████");
  252.     printat(5,17,13,0,"Color 13     ████████");
  253.     printat(5,18,14,0,"Color 14     ████████");
  254.     printat(5,19,15,0,"Color 15     ████████");
  255.  
  256.     delay(3000);
  257.     printat(42,12,15,1,"     Press any key to end...");
  258.     flushkeys();
  259.     while(!kbhit()) {
  260.         for(i=1;i<16;i++)
  261.             rgb(i,random(63),random(63),random(63));
  262.         delay(1000);
  263.         }
  264.     set_default_palette();
  265.     delay(2000);
  266.     demo4window.hide();
  267. }
  268.  
  269. //**************************************************************************
  270.  
  271. void demo5()
  272. {
  273.     Twindow demo5window;
  274.  
  275.     demo5window.init(5,5,76,12,15,1,0,0);
  276.     demo5window.show();
  277.  
  278.     printc(7,15,1,"As you know, if you try to use colors 8 through 15 as");
  279.     printc(8,15,1,"background colors, the foreground begins to blink against your will.");
  280.     delay(2000);
  281.     printc(10,14,1,"Well now you're in control!");
  282.  
  283.     disable_blink();
  284.     delay(1000);
  285.     printc(15,0,15,"     Black on white    ");
  286.     delay(1000);
  287.     printc(17,5,14,"   Magenta on yellow   ");
  288.     delay(1000);
  289.     printc(19,15,9,"    Any combination!   ");
  290.     delay(2000);
  291.  
  292.     printc(22,15,0,"Press any key...");
  293.  
  294.     flushkeys();
  295.     getch();
  296.     enable_blink();
  297.     demo5window.hide();
  298. }
  299.  
  300. //**************************************************************************
  301.  
  302. void demo6()
  303. {
  304.     Twindow demo6window;
  305.     demo6window.init(5,5,76,13,15,1,0,0);
  306.     demo6window.show();
  307.  
  308.     printc(7,15,1,"Ever want to turn the screen off during a massive screen");
  309.     printc(8,15,1,"drawing routine so that the user doesn't have to (or doesn't");
  310.     printc(9,15,1,"get to) see it all happening?");
  311.     delay(3000);
  312.     printc(11,14,1,"Press any key to DO IT!");
  313.  
  314.     flushkeys();
  315.     getch();
  316.     flushkeys();
  317.     disable_refresh();
  318.     demo6window.hide();
  319.  
  320.     Twindow w1,w2,w3,w4,w5;
  321.     w1.init(15,5,25,10,15,1,1,7);
  322.     w1.show();
  323.     w2.init(25,7,35,12,15,2,1,7);
  324.     w2.show();
  325.     w3.init(35,9,45,14,15,3,1,7);
  326.     w3.show();
  327.     w4.init(45,11,55,16,15,4,1,7);
  328.     w4.show();
  329.     w5.init(55,13,65,18,15,5,1,7);
  330.     w5.show();
  331.  
  332.     delay(1000);
  333.     enable_refresh();
  334.     delay(1500);
  335.  
  336.     printc(22,15,0,"Press any key...");
  337.     flushkeys();
  338.     getch();
  339. }
  340.  
  341. //**************************************************************************
  342.  
  343. void outro()
  344. {
  345.     Twindow outrowindow;
  346.     outrowindow.init(4,6,77,18,14,2,0,0);
  347.     outrowindow.title("Summary");
  348.     outrowindow.show();
  349.  
  350.     printc(8,14,2,"These are the highlights...the raw materials for your");
  351.     printc(9,14,2,"creative ideas. Note that while this demo was in text mode,");
  352.     printc(10,14,2,"these functions work equally as well in graphics mode.");
  353.     printc(11,14,2,"Please read the complete documentation file for specific");
  354.     printc(12,14,2,"information on using these functions in your programs.");
  355.     printc(14,14,2,"Thank you for previewing software from Ludicrous Data.");
  356.     printc(16,15,2,"Press any key now to return to DOS...");
  357.  
  358.     flushkeys();
  359.     getch();
  360.     flushkeys();
  361.     outrowindow.hide();
  362. }
  363.